<%--
 *
 * @author Shengzhao Li
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="commons/taglib-header.jsp" %>
<html>
<head>
    <title>用户</title>
</head>
<body>


<div class="row">
    <div class="col-lg-2 col-sm-3 sidebar column">
        <ul id="navleft" class="nav nav-pills nav-stacked">
        </ul>
    </div>

    <div class="col-lg-10 col-sm-9 main column">

        <h2 class="page-header">创建用户</h2>

        <form:form modelAttribute="userTableDto" cssClass="form-horizontal"  action="${contextPath}/user/save" method="post">

            <div class="form-group">
                <label class="col-sm-2 control-label">用户名<em class="text-danger">*</em></label>
                <div class="col-sm-10">
                    <form:input path="username" cssClass="form-control" placeholder="用户名"
                                required="required" maxlength="255"/>
                    <form:errors path="username" cssClass="label label-warning"/>
                    <p class="help-block">长度不少于6</p>
                </div>
            </div>
            <div class="form-group">
                <label for="password" class="col-sm-2 control-label">密码<em
                        class="text-danger">*</em></label>

                <div class="col-sm-10">
                    <form:password path="password" cssClass="form-control" id="password"
                                   placeholder="密码" required="required" maxlength="255"/>
                    <form:errors path="password" cssClass="label label-warning"/>
                    <p class="help-block">长度不少于8</p>
                </div>
            </div>
            <div class="form-group">
                <label for="rePassword" class="col-sm-2 control-label">确认密码<em
                        class="text-danger">*</em></label>
                <div class="col-sm-10">
                    <form:password path="repassword" cssClass="form-control" id="rePassword"
                                   placeholder="确认密码" required="required" maxlength="255"/>
                    <form:errors path="repassword" cssClass="label label-warning"/>
                    <p class="help-block">长度不少于8</p>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">权限<em class="text-danger">*</em></label>

                <div class="col-sm-10">
                    <form:checkboxes path="privileges" items="${userTableDto.allPrivileges}" itemValue="value"
                                     itemLabel="label" delimiter="<br/>"/>
                    <form:errors path="privileges" cssClass="label label-warning"/>
                    <p class="help-block">权限至少选择一个</p>
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-2"></div>
                <div class="col-sm-10">
                    <button type="submit" class="btn btn-primary"><em class="glyphicon glyphicon-ok-sign"></em>保存</button>
                    <a href="overview">返回</a>
                </div>
            </div>
        </form:form>
    </div>
</div>


<script>
    <%--Reset password values--%>
    document.getElementById("password").value = "${formDto.password}";
    document.getElementById("rePassword").value = "${formDto.rePassword}";
</script>
</body>
</html>
